module.exports = (app) => {
    var express = require("express");
    var router = express.Router();
    var watch = require("./watch");
    const common = require("../models/common");
    const article = require("../models/Article");

    watch.watch();

    // 获取文章列表
    router.get("/article/list", async (req, res, next) => {
        article.find({}, function (err, data) {
            if (err) {
                common.sendJsonResponse(res, 500, err);
                return;
            }
            common.sendResponse(res, 200, data);
        });
    });

    // 查询一篇文章
    router.get("/article/list/:id", async (req, res, next) => {
        article.findOne({'idNo': req.params.id}, function (err, data) {
            if (err) {
                common.sendJsonResponse(res, 500, err);
                return;
            }
            common.sendResponse(res, 200, data);
        })
    })

    app.use("/web", router);
};
